n=5;

%mine
movingPoints = [ [127	112	20]' [125	118	12]' [127	153	10]' [126	81	24]' [50	149	6]' ];
fixedPoints = [ [132	116	20]' [131	123	12]' [130	157	14]' [136	85	21]' [52	148	1]' ];


%ran's
%movingPoints = [ [113    86    25]' [ 160    55    11]' [ 101   159    23]' [160    54     9]' [ 126   125     1]' ];
%fixedPoints = [ [121    90    21]' [ 173    63     8]' [100   163    23]' [171    62     7]' [133   131     2]' ];


miss1 = mean(sqrt(sum((movingPoints - fixedPoints).^2)));
[rotation, translation] = absoluteOrientation(movingPoints',fixedPoints');

afterTranslationMovingPoints = zeros(3,n);
for i=1:3
    afterTranslationMovingPoints(i,:) = movingPoints(i,:) + translation(i);
end

t = rotation * afterTranslationMovingPoints;

miss2 = mean(sqrt(sum((t - fixedPoints).^2)));

% this part will generate the data for the graphs

transNC = zeros(1,5);
rotNC = zeros(1,5);

transMI = zeros(1,5);
rotMI = zeros(1,5);

for i=0:4
    transNC(1,i+1)= Normalized_Cross_Correlation('t2.nii',sprintf('t1_shift%01d.nii',i));
    rotNC(1,i+1)= Normalized_Cross_Correlation('t2.nii',sprintf('t1_rotate%01d.nii',i));
    
    transMI(1,i+1)= Mutual_Informaion('t2.nii',sprintf('t1_shift%01d.nii',i));
    rotMI(1,i+1)= Mutual_Informaion('t2.nii',sprintf('t1_rotate%01d.nii',i));
end

figure(1);
plot([0 1 2 3 4],transMI,'.-g')
hold on;
plot([0 1 2 3 4],transNC,'.-r')

xlabel('Shifted image number');
ylabel('NCC/MI value');

figure(2);

plot([0 1 2 3 4],rotMI,'.-g')
hold on;
plot([0 1 2 3 4],rotNC,'.-r')

xlabel('Rotated image number');
ylabel('NCC/MI value');